<?php

namespace App\Console\Commands;

use App\Http\Logic\TickersLogic;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class UpdateChainsCommand extends Command
{
    protected $signature = 'chains:update';

    protected $description = '更新最新支持的区块链';

    public function handle()
    {
        $num = TickersLogic::updateChains();

        if(false === $num) {
            echo "区块链更新失败,原因：".TickersLogic::getErrorMessage(), PHP_EOL;

            Log::channel('daily')->error(TickersLogic::getErrorMessage());
        }

        echo "区块链更新成功，更新数量：".$num, PHP_EOL;

        $num = TickersLogic::updateMarkers('SPOT');

        if(false === $num) {
            echo "币币更新失败,原因：".TickersLogic::getErrorMessage(), PHP_EOL;

            Log::channel('daily')->error(TickersLogic::getErrorMessage());
        }

        echo "币币更新成功，更新数量：".$num, PHP_EOL;
    }
}
